/*
 * Copyright © 2011 Breachwalls & Company Inc. and other authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.breachwalls.h2p.plugin.prescription.persistence.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.breachwalls.h2p.platform.persistence.AbstractEntity;
import com.breachwalls.h2p.platform.persistence.entity.Hospital;
import com.breachwalls.h2p.platform.persistence.entity.Pharmacy;

/**
 * 処方箋エンティティ.
 * @author Ken Todoroki
 * @version $Revision$
 */
@Entity
@Table(name = "T_PRESCRIPTION")
public class Prescription extends AbstractEntity {

    private static final long serialVersionUID = 1L;

    @Column(name = "IMAGE_URL", nullable = false, length = 64)
    private String imageUrl;

    @Column(name = "STATUS", nullable = false, length = 16)
    private String status;

    // FIXME Lengthがこれで良いのか確認しないといけません
    @Column(name = "PROCESS_INSTANCE_ID", length = 64)
    private String processInstanceId;

    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "HOSPITAL_ID", nullable = false)
    @JoinColumn(name = "HOSPITAL_ID")
    private Hospital hospital;

    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "PHARMACY_ID", nullable = false)
    @JoinColumn(name = "PHARMACY_ID")
    private Pharmacy pharmacy;

    @OneToMany(mappedBy = "prescription")
    private Set<PrescriptionComment> prescriptionComments;

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public Hospital getHospital() {
        return hospital;
    }

    public void setHospital(Hospital hospital) {
        this.hospital = hospital;
    }

    public Pharmacy getPharmacy() {
        return pharmacy;
    }

    public void setPharmacy(Pharmacy pharmacy) {
        this.pharmacy = pharmacy;
    }

    public Set<PrescriptionComment> getPrescriptionComments() {
        return prescriptionComments;
    }

    public void setPrescriptionComments(Set<PrescriptionComment> prescriptionComments) {
        this.prescriptionComments = prescriptionComments;
    }

}
